<template>
  <HomePanel title="人气推荐" sub-title="人气爆款 不容错过" ref="target">
    <template #content>
      <Transition name="fade">
        <ul class="goods-list" v-if="result.length">
          <li v-for="item in result" :key="item.id">
            <RouterLink to="/">
              <img v-lazy="item.picture" alt="">
              <p class="name">{{ item.title }}</p>
              <p class="desc">{{ item.alt }}</p>
            </RouterLink>
          </li>
        </ul>
        <HomeSkeleton v-else bg="#f0f9f4" width="90px" />
      </Transition>
    </template>
  </HomePanel>
</template>
<script lang="ts" setup>
import { findHot } from '../../api/home'
import HomePanel from './home-panel.vue';
import HomeSkeleton from './home-skeleton.vue';
import { useLazyData } from '../../hooks/index'
const { target, result } = useLazyData(findHot)
</script>
<style lang="less" scoped>
@import '../../assets/styles/mixins.less';
@import '../../assets/styles/variables.less';

.goods-list {
  display: flex;
  justify-content: space-between;
  height: 440px;

  li {
    width: 306px;
    height: 406px;
    .hoverShadow();

    img {
      width: 306px;
      height: 306px;
      object-fit: cover;
    }

    p {
      font-size: 22px;
      padding-top: 12px;
      text-align: center;
    }

    .desc {
      color: #999;
      font-size: 18px;
    }
  }
}
</style>